package com.vgemv.jsutilitysdkdemo.module.BottomInputBar;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;

import androidx.appcompat.app.AppCompatActivity;

//import com.vgemv.jsutilitysdk.Display.JsActivityDisplayManager.JsActivityDisplayManager;
//import com.vgemv.jsutilitysdk.Display.JsDisplayStyle;
import com.vgemv.jsutilitysdk.InputBar.JsBottomInputBarBet;
import com.vgemv.jsutilitysdk.InputBar.JsBottomInputBarBetaCallback;
import com.vgemv.jsutilitysdk.InputBar.JsBottomInputBarBetaVm;
import com.vgemv.jsutilitysdk.JsButton.JsButton;
import com.vgemv.jsutilitysdk.log.JsLogManager;

public class BottomInputBarActivity extends AppCompatActivity {

    private FrameLayout mv_bottomBarContainer;
    private RelativeLayout mrl_root;

    public Handler mHandler = new Handler(Looper.getMainLooper());

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);


        mrl_root = new RelativeLayout(this);
        mrl_root.setId(View.generateViewId());
        setContentView(mrl_root);

        //BottomInputBar
        {
            mv_bottomBarContainer = new FrameLayout(this);
            mv_bottomBarContainer.setId(View.generateViewId());
            mrl_root.addView(mv_bottomBarContainer);

            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,JsBottomInputBarBetaVm.inputBarHegiht);
            lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            mv_bottomBarContainer.setLayoutParams(lp);

            JsBottomInputBarBet inputBar = new JsBottomInputBarBet();
            inputBar.moveToParentView(this,mv_bottomBarContainer);
            inputBar.mActivity = this;
            inputBar.mCallback = new JsBottomInputBarBetaCallback() {
                @Override
                public JsBottomInputBarBetaVm jsBottomInputBarBetaSetVm(JsBottomInputBarBet bar) {
                    return null;
                }

                @Override
                public void jsBottomInputBarClickPick(JsBottomInputBarBet bar) {
                    if(bar.isPicked()) {
                        bar.unpick();
                    }
                    else {
                        bar.pick();
                    }
                }

                @Override
                public void jsBottomInputBarClickShare(JsBottomInputBarBet bar) {

                }

                @Override
                public void jsBottomInputBarClickLike(JsBottomInputBarBet bar, JsButton likeButton) {
                    bar.like();
                    bar.oneMoreLike();
                }

                @Override
                public void jsInputBoxPublish(JsBottomInputBarBet bar, String text) {
                    JsLogManager.logc_d("BottomInputBarActivity","text is %s",text);
                }
            };
        }

    }
}